<template>
  <div class="mainP">
    <div class="title">
      <span>纪念馆管理</span>
    </div>
    <div @click="editC" class="add">+ 创建纪念馆</div>
    <!-- <div class="own"></div> -->
    <div class="title">
      <span>已建纪念馆</span>
    </div>
    <ul class="roomlist" v-for="(item,index) in data" :key="index">
      <van-swipe-cell :right-width="45" >
        <li @click="detailPage(item)" >
          <img :src="item.picurlofdeath">
          <van-cell-group>
            <van-cell :title="item.username" is-link :label="item.deathdate" />
          </van-cell-group>
        </li>
        <span slot="right" @click="deleteC(item.id)">删除</span>
      </van-swipe-cell>
    </ul>
    <span class="value" @click="message">久久怀念网使用协议</span>
  </div>
</template>

<script>
export default {
  data () {
    return {
      ms: true,
      userid: '11',
      data: []
    }
  },
  created () {
    this.getData()
    this.$store.commit('USER_ID', this.userid)
  },
  methods: {
    getData () {
      var that = this
			
          this.$axios.get("/huainianwang/memorial/app/getMemorialList?userid="+this.userid+"")
          // this.$axios.get("/memorial/app/getMemorialList?userid="+this.userid+"")
					.then(function(res){
						// alert(1)
            // that.$router.push('/')
            that.data = res.data.object
					},function(err){
					}).catch(function(error){
					});
			
    },
    editC () {
      
      if (this.ms) {
        
        this.$router.push('/edit')
        this.mS = false
      } else {
        this.$toast('请先阅读久久怀念网使用协议')
      }
    },
    deleteC (id) {
       var that = this
      this.$dialog.confirm({
        title: '删除墓园',
        message: '删除后所有的资料将不可挽回，您确认删除甚至承担可能的相应法律责任吗？'
      }).then(() => {
					this.$axios.get("/huainianwang/memorial/app/delMemorialInfoById?mid="+id+"")
					.then(function(res){
            that.getData()
					},function(err){
					}).catch(function(error){
					});
      }).catch(() => {
        // on cancel
      });
    },
    detailPage (item) {
      window.localStorage.removeItem('item')
      window.localStorage.setItem('item', JSON.stringify(item))
      this.$router.push({
        path: '/detail-page',
        query: {
          id: item.id
        }
      })
      this.$store.commit('GUAN_INFO', {id: item.id})
    },
    message () {
      this.$router.push('/message')
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.roomlist{
  li {
    display: flex;
    padding: 10px;
    img {
      height: 80px;
      width: 40%;
    }
  }
}
.title{
  width: 100%;
  height: 40px;
  text-align: center;
  line-height: 40px;
  background: #31a2c8;
  color: #fff;
}
.value{
  color: #31a2c8;
  font-size: 13px;
  text-align: center;
  width: 100%;
  position: fixed;
  bottom: 0;
  display: block;
  height: 40px;
  line-height: 40px;
  text-decoration: underline;
}
.add {
    width: 90%;
    margin: 10px auto;
    height: 80px;
    line-height: 80px;
    /* padding: 10px 0; */
    border: 1px dotted #ccc;
    text-align:center;
    color: #31a2c8;
  }
</style>
<style>
.van-nav-bar .van-icon{
    color: #fff !important;
  }
.mainP .van-cell-group{
    width: 100%;
  }
.mainP .van-cell__label{
    line-height: 30px;
  }
  .mainP .van-icon {
    position: absolute;
    right: 15px;
    top: 12px;
  }
  
</style>
